package com.csx.governance.traffic.route.model.swimlane;

import cn.hutool.core.util.ObjectUtil;
import com.csx.governance.traffic.route.model.ConditionExpression;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

/**
 * 泳道路由规则
 * @author cuisongxu
 * @date 2023/2/22 19:24
 */
@Getter
@Setter
@NoArgsConstructor
public class SwimLaneRule {

    /**
     * 条件表达式，满足该条件表达式则认为满足该泳道规则
     */
    private ConditionExpression conditionExpression = new ConditionExpression();

    /**
     * 匹配该泳道规则后选用的策略
     */
    private SwimLaneStrategy swimLaneStrategy = new SwimLaneStrategy();

    /**
     * 是否启用该规则
     */
    private Boolean enabled;

    /**
     * 默认启用
     * @return
     */
    public Boolean getEnable() {
        if(ObjectUtil.isEmpty(enabled)) {
            return true;
        }
        return enabled;
    }
}
